oo::class create CloseFrame {
    variable Cmd
    
    constructor {path cmd {dir {nw}}} {
        set closeButton [image create photo -format png -data {
            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
            Sv4BrOdX/h8bIYYAAAAASUVORK5CYII=
        }]
 
        set inactiveImg [image create photo -width 14 -height 14]
        $inactiveImg copy $closeButton -from 0 0 14 14
        set activeImg [image create photo -width 14 -height 14]
        $activeImg cop $closeButton -from 28 0 42 14
        
        ttk::labelframe $path -labelanchor $dir
        set closeLabel [ttk::label $path.lb -image $inactiveImg]
        $path configure -labelwidget $closeLabel
        
        set Cmd $cmd
        bind $closeLabel <Leave> "$closeLabel configure -image $inactiveImg"
        bind $closeLabel <Enter> "$closeLabel configure -image $activeImg"
        bind $closeLabel <Button-1> "[self] onFrameClose"
    }
    
    method onFrameClose {} {
        uplevel #0 [list eval $Cmd]
    }
}